package com.amat0urheu.dao;



import com.amat0urheu.pojo.race.RaceParticipant;
import com.amat0urheu.pojo.race.TeamRank;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface RaceParticipantMapper extends BaseMapper<RaceParticipant> {
/*    limit #{pageSize} OFFSET #{start}*/
    @Select(" SELECT * FROM mc_race_participants WHERE rid = #{rid} " )
    List<RaceParticipant> getAllparticipants(Integer rid);
    @Select(" SELECT * FROM mc_race_current_ranking where  rid = #{rid} order by  teamScore  DESC" )
    List<TeamRank> getCurrentRanking(Integer  rid);
    @Select(" SELECT count(*) FROM mc_race_participants where  rid = #{rid} and user= #{user}" )
    int getuserParticipated(Integer rid, String user);

    @Insert("insert into mc_race_participants values ( null,#{rid},#{user},#{teamName},#{role})")
    void takePartInRace(Integer rid, String user, String teamName, String role);
    @Select(" SELECT count(*) FROM mc_race_participants where  rid = #{rid} and team= #{teamName}" )
    int getNumofTeam(Integer rid,String teamName);
}